package o;

import android.content.Intent;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
import android.os.RemoteException;
import com.huawei.gamebox.plugin.gameservice.bean.GameInfo;
import com.huawei.gamebox.plugin.gameservice.bean.GetGameUpdateInfoResp;
import com.huawei.gamebox.plugin.gameservice.view.GameServiceShowDialogActivity;
import java.util.HashMap;
import org.json.JSONObject;

public class ezy {
    private static ezy ˊ;
    private HashMap<String, Long> ˋ = new HashMap();
    private HashMap<String, GetGameUpdateInfoResp> ˎ = new HashMap();
    private String ˏ;
    private HashMap<String, fad> ॱ = new HashMap();

    private ezy() {
    }

    public static synchronized ezy ˏ() {
        ezy o_ezy;
        synchronized (ezy.class) {
            if (ˊ == null) {
                ˊ = new ezy();
            }
            o_ezy = ˊ;
        }
        return o_ezy;
    }

    void ॱ(String str, fad o_fad) {
        this.ॱ.put(str, o_fad);
    }

    private fad ˊ(String str) {
        return (fad) this.ॱ.get(str);
    }

    void ˏ(String str, GetGameUpdateInfoResp getGameUpdateInfoResp) {
        this.ˎ.put(str, getGameUpdateInfoResp);
    }

    private GetGameUpdateInfoResp ʻ(String str) {
        return (GetGameUpdateInfoResp) this.ˎ.get(str);
    }

    void ˋ(String str, long j) {
        this.ˋ.put(str, Long.valueOf(j));
    }

    long ˏ(String str) {
        if (this.ˋ.containsKey(str)) {
            return ((Long) this.ˋ.get(str)).longValue();
        }
        return -1;
    }

    boolean ॱ(GameInfo gameInfo) {
        if (!dof.ˋ(gameInfo.getSdkVersionCode())) {
            try {
                if (Integer.parseInt(gameInfo.getSdkVersionCode()) >= 70202000) {
                    return true;
                }
            } catch (Exception e) {
                Logger.ˎ("GameUpdateManager", "parse gameInfo SdkVersionCode error");
            }
        }
        return false;
    }

    public void ˎ(String str) {
        GetGameUpdateInfoResp ʻ = ʻ(str);
        fad ˊ = ˊ(str);
        if (ʻ != null && ˊ != null) {
            String jSONObject;
            try {
                ʻ.setRtnCode_(7);
                JSONObject jSONObject2 = new JSONObject(ʻ.toJson());
                jSONObject2.remove("newVersion");
                jSONObject = jSONObject2.toString();
            } catch (Exception e) {
                Logger.e("GameUpdateManager", "String to Json exception");
                jSONObject = null;
            }
            try {
                if (this.ˏ != null) {
                    ˊ.ˋ(this.ˏ, jSONObject);
                }
            } catch (RemoteException e2) {
                Logger.e("GameUpdateManager", "callback response exception");
            }
        }
    }

    void ˊ(fad o_fad, GetGameUpdateInfoResp getGameUpdateInfoResp) {
        String jSONObject;
        try {
            JSONObject jSONObject2 = new JSONObject(getGameUpdateInfoResp.toJson());
            jSONObject2.remove("newVersion");
            jSONObject = jSONObject2.toString();
        } catch (Exception e) {
            Logger.e("GameUpdateManager", "String to Json exception");
            jSONObject = null;
        }
        try {
            if (this.ˏ != null) {
                o_fad.ˋ(this.ˏ, jSONObject);
            }
        } catch (RemoteException e2) {
            Logger.e("GameUpdateManager", "callback response exception");
        }
    }

    public void ॱ(String str) {
        this.ˏ = str;
    }

    public void ˋ(String str) {
        this.ॱ.remove(str);
        this.ˋ.remove(str);
        this.ˎ.remove(str);
    }

    public void ˋ(final GameInfo gameInfo) {
        if (gameInfo != null) {
            GetGameUpdateInfoResp ʻ = ʻ(gameInfo.getAppId());
            if (ʻ != null) {
                final Intent intent = new Intent(ContentManager.getInstant().getContext(), GameServiceShowDialogActivity.class);
                intent.putExtra("appId", gameInfo.getAppId());
                intent.putExtra("packageName", gameInfo.getPackageName());
                intent.putExtra("isForceUpdate", ʻ.newVersion_.ˏ());
                intent.putExtra("newFeatures", ʻ.newVersion_.ˎ());
                intent.putExtra("dialogClass", fan.class.getName());
                Handler anonymousClass4 = new Handler(this, Looper.getMainLooper()) {
                    final /* synthetic */ ezy ˋ;

                    public void handleMessage(Message message) {
                        fab.ˎ().ˏ(gameInfo, intent, this.ˋ.ˊ(gameInfo.getAppId()));
                    }
                };
                anonymousClass4.sendMessage(anonymousClass4.obtainMessage());
            }
        }
    }
}
